<template>
  <div>
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>角色管理</el-breadcrumb-item>
      <el-breadcrumb-item>角色列表</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card>
      <el-row>
        <el-col>
          <el-button type="primary">添加角色</el-button>
          <el-table
            :data="roleList"
            style="width: 100%"
            :default-sort="{prop: 'roleName', order: 'descending'}"
          >
           
          
         <!-- 展开列 -->
            <el-table-column type="expand">
              <template slot-scope="scope">
                <el-row
                  :class="['bdbottom',i1===0 ? 'bdtop':'' ]"
                  v-for="(item1, i1) in scope.row.childrenPermissionList"
                  :key="item1.id"
                >
                  <el-col :span="5">
                    <el-tag closable>{{item1.permissionName}}</el-tag>
                    <i class="el-icon-caret-right"></i>
                  </el-col>

                  <el-col :span="19">
                    <!-- 二级权限 -->
                    <el-row
                      :class="[i2===0 ? '':'bdtop' ]"
                      v-for="(item2,i2) in item1.childrenList"
                      :key="item2.id"
                    >
                      <el-col :span="6">
                        <el-tag type="success" closable>{{item2.permissionName}}</el-tag>
                        <i class="el-icon-caret-right"></i>
                      </el-col>
                      <el-col :span="18">
                        <el-tag
                          :class="[i3===0 ? '':'bdtop' ]"
                          type="warning"
                          closable
                          v-for="(item3,i3) in item2.childrenList"
                          :key="item3.id"
                        >{{item3.permissionName}}</el-tag>
                      </el-col>
                    </el-row>
                  </el-col>
                </el-row>
              </template>
            </el-table-column>
    
   



     <el-table-column type="index"></el-table-column>
    <el-table-column
      prop="roleName"
      label="角色名称"
      sortable
      width="180">
    </el-table-column>
    <el-table-column      prop="roleDescription"      label="描述"      sortable      width="180">
    </el-table-column>
    <el-table-column   label="操作"   >
     <template >
  <el-button>编辑</el-button>
  <el-button>删除</el-button>
  <el-button>分配权限</el-button>
    </template>
    </el-table-column>
  </el-table>
   </el-col>
 </el-row>
</el-card>
    </div>
</template>
<script>
export default {
  data() {
    return {
      roleList: []
    };
  },
  created() {
    this.getRolesList();
  },
  methods: {
    async getRolesList() {
      const { data: res } = await this.$http.get(
        "user-permission/getThisUserPermission?userId=1"
      );
      if (res.code !== 200) {
        this.$message.error("请求失败！");
      }
      this.roleList = res.data;
      console.log(this.roleList);
    }
  }
};
</script>
<style lang="less" scoped>
// .el-main ,.el-table{
//   line-height: 0;
// }
.el-tag {
  margin: 7px;
}
.bdtop {
  border-top: 1px solid #eee;
}
.bdbottom {
  border-bottom: 1px solid #eee;
}
</style>